package de.hhbk.azubiverwaltung.userinterface;

import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import de.hhbk.azubiverwaltung.business.beans.ZeugnisAbfragenBBean;
import de.hhbk.azubiverwaltung.entites.Zeugnis;
import de.hhbk.azubiverwaltung.entites.Zeugnis_;

public class PanelArchiv extends JPanel{
	
	JLabel lblSearch;
	JTextField txtSearch;
	JButton btnSearch;
	JLabel lblDescription;
	PanelArchiv panel;
	
	
	public PanelArchiv(){
	
		panel = this;
		this.setLayout(new GridLayout());


		txtSearch = new JTextField();
		btnSearch = new JButton("Suche");
		btnSearch.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				AzubiSearchDialog dialog = new AzubiSearchDialog(panel, txtSearch.getText());
				
			}
		});
		

		GridBagLayout layout = new GridBagLayout();
		ZeugnisAbfragenBBean abfrage = new ZeugnisAbfragenBBean();
		this.setLayout(layout);
		
		GridBagConstraints ctfAzubiSucheTxt = new GridBagConstraints();
		ctfAzubiSucheTxt.gridx = 1;
		ctfAzubiSucheTxt.gridy = 1;
		ctfAzubiSucheTxt.fill = GridBagConstraints.BOTH;
		ctfAzubiSucheTxt.ipadx = 100;
		
		GridBagConstraints ctfAzubiSucheBtn = new GridBagConstraints();
		ctfAzubiSucheBtn.gridx = 2;
		ctfAzubiSucheBtn.gridy = 1;
		ctfAzubiSucheBtn.fill = GridBagConstraints.BOTH;
		ctfAzubiSucheBtn.ipadx = 100;

		this.add(txtSearch, ctfAzubiSucheTxt);
		this.add(btnSearch, ctfAzubiSucheBtn);
		

	}
	
	public void initTable(List<Zeugnis> zeugnisList){
		
		ZeugnisAbfragenBBean abfrage = new ZeugnisAbfragenBBean();
		
		GridBagConstraints ctfAzubiTbl = new GridBagConstraints();
		ctfAzubiTbl.gridx = 1;
		ctfAzubiTbl.gridy = 2;
		ctfAzubiTbl.gridwidth = 8;
		ctfAzubiTbl.gridheight = 8;
		ctfAzubiTbl.fill = GridBagConstraints.BOTH;
		ctfAzubiTbl.ipadx = 100;
		
		this.add(new ZeugnisTable(abfrage.getAllZeugnise()), ctfAzubiTbl);
	}
	
}
